/**
 * @fileOverview toolbar
 * @author huangtonger@aliyun.com
 */

const Util = require('../util/');
const Base = require('../simpleBase');

class Component extends Base {
  getDefaultCfg() {
    return {
      /**
       * 类型
       * @type {string}
       */
      type: 'toolbar',

      /**
       * dom 容器
       * @type {dom}
       */
      container: null
    };
  }

  init() {
    this._initContainer();
  }

  _initContainer() {
    let container = this.container;
    if (container) {
      if (Util.isString(container)) {
        container = document.getElementById(container);
      }
    } else {
      throw new Error('please set the container for the toolbar !');
    }
    const commands = container.getElementsByClassName('command');
    this.commands = commands;
  }

  getCommandDoms() {
    return this.commands;
  }
}

module.exports = Component;
